import request from '@/utils/request'

// 报表统计相关接口
export interface ProjectStats {
  totalProjects: number
  activeProjects: number
  completedProjects: number
  overdueProjects: number
  completionRate: number
}

export interface TaskStats {
  totalTasks: number
  completedTasks: number
  inProgressTasks: number
  pendingTasks: number
  overdueTasks: number
  taskCompletionRate: number
}

export interface TimeStats {
  totalHours: number
  billableHours: number
  nonBillableHours: number
  averageHoursPerDay: number
  totalRecords: number
}

export interface MemberStats {
  totalMembers: number
  activeMembers: number
  inactiveMembers: number
  newMembersThisMonth: number
}

export interface ProjectProgressStats {
  projectId: number
  projectName: string
  progress: number
  status: string
  startDate: string
  endDate: string
  totalTasks: number
  completedTasks: number
}

export interface TaskStatusStats {
  status: string
  statusName: string
  count: number
  percentage: number
}

export interface TimeTrackingStats {
  date: string
  hours: number
  recordCount: number
  projectName: string
  taskName: string
  userName: string
}

export interface ReportStatsQuery {
  projectId?: number
  startDate?: string
  endDate?: string
}

// 获取项目统计
export function getProjectStats() {
  return request({
    url: '/pm/report/project-stats',
    method: 'get'
  })
}

// 获取任务统计
export function getTaskStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/task-stats',
    method: 'get',
    params
  })
}

// 获取时间统计
export function getTimeStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/time-stats',
    method: 'get',
    params
  })
}

// 获取成员统计
export function getMemberStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/member-stats',
    method: 'get',
    params
  })
}

// 获取项目进度统计
export function getProjectProgressStats() {
  return request({
    url: '/pm/report/project-progress',
    method: 'get'
  })
}

// 获取任务状态分布统计
export function getTaskStatusStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/task-status',
    method: 'get',
    params
  })
}

// 获取时间跟踪统计
export function getTimeTrackingStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/time-tracking',
    method: 'get',
    params
  })
}

// 获取综合报表统计
export function getComprehensiveStats(params?: ReportStatsQuery) {
  return request({
    url: '/pm/report/comprehensive',
    method: 'get',
    params
  })
}
